<?php 
   	require_once 'simple_html_dom.php';
   	
    function getProduct($path){
    	
    	$strFile = "";
    	
    	ini_set('default_socket_timeout', 120);
    	
    	$html = file_get_html($path);
    	
    	// lay data tu the div
 		$aprod = $html->find("a[rel='bookmark']");
 		
 		$result = "Result : ".sizeof($aprod)." Product<br/>";
 		
 		// TODO : mock object to break data
 		$tmp = 0;
 		
 		foreach ($aprod as $item1) {
 			
 			$strFile = $strFile.$item1->innertext.",".$item1->getAttribute("href")."\n";
 		    $result = $result."<input type='hidden' class='hdProd' value='".$item1->getAttribute("href")."' />";
 			
 		    // TODO : mock code
 		    $tmp++;
 		    if($tmp > 5) break;
 		}
 		
 		$file = fopen("product.txt",'a');
 	    fwrite($file,$strFile);
 		
 	    echo $result;
    }
    
   getProduct($_POST['url']);
   
?>